var face_total = new EventSource('/face_total');
face_total.onmessage = function(event) {
	var arrs = event.data.substring(1, event.data.length - 1).split(",");
	document.getElementById('face_item_count').innerText = arrs[0];
	document.getElementById('face_execute_count').innerText = arrs[1];
	document.getElementById('face_link_count').innerText = arrs[2];
	document.getElementById('face_link_execute_count').innerText = arrs[3];
};

var source = new EventSource('/statistic');
source.onmessage = function(event) {
	var arrs = event.data.substring(1, event.data.length - 1).split(",");
	var count = $("#serverMonitorCount").val();
	for (var i = 0; i < count; i++) {
		console.log(arrs[i])
		var error = arrs[i].indexOf("error");
		if (error!=-1 || arrs[i] == "  4 (100% 丢失)，") {
			arrs[i] = " ERROR";
			document.getElementById("server_monitor_" + i).innerText = arrs[i];
			$("#server_monitor_" + i).css("color", "red");
		} else {
			document.getElementById("server_monitor_" + i).innerText = arrs[i];
			$("#server_monitor_" + i).css("color", "green");
		}
	}
};